﻿using Abp;
using Abp.AutoMapper;
using Abp.Dependency;
using Abp.Modules;
using Abp.Reflection.Extensions;
using Mt.Site.Application.Security.Recaptcha;
using Mt.Site.Core;

namespace Mt.Site.Application
{
    [DependsOn(
        typeof(MtSiteCoreBaseModule)
        )]
    public class MtSiteApplicationBaseModule : AbpModule
    {
        public override void PreInitialize()
        {
            //Adding custom AutoMapper mappings
            Configuration.Modules.AbpAutoMapper().Configurators.Add(CustomDtoMapper.CreateMappings);

            Configuration.Auditing.Selectors.Clear();
            Configuration.Auditing.Selectors.Add(
                new NamedTypeSelector("Abp.BackEndAppServices", type => typeof(IBackEndAppService).IsAssignableFrom(type))
                );
        }

        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(typeof(MtSiteApplicationBaseModule).GetAssembly());
        }
        public override void PostInitialize()
        {
            IocManager.RegisterIfNot<IRecaptchaValidator, NullRecaptchaValidator>();
        }
    }
}